<template>
  <view class="ikz-school">
    <ikz-loading :css-data="loading_css"></ikz-loading>
    <ikz-topbg></ikz-topbg>
    <view class="ikz-seach">
      <image class="ikz-search-img" src="/static/campus/search.png"></image>
      <input
        class="ikz-search-input"
        placeholder="请输入关键词搜索学校"
        @input="eventHandle"
      />
    </view>
    <image class="ikz-top-bg" :src="service_img" mode="widthFix"></image>
    <ikz-list
      :show-data="list_data"
      :css-data="list_css"
      @returnList="returnList"
    ></ikz-list>
    <view class="ikz-ad">德鑫校园温馨提示：</view>

    <view class="ikz-ad-line2"
      >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;为营造优质校园环境，提供高效服务，德鑫校园平台仅对本校同学开放。首次选择校区务必慎重，选定后原则上不可更改。若有特殊情况需修改，烦请联系平台官方，我们会严格核实学生证等信息，一旦发现造假，将取消平台使用资格。感谢大家的理解与配合！</view
    >
  </view>
</template>

<script>
import ikzLoading from "@/pages/Component/Public/Loading/loading.vue";
import ikzList from "@/pages/Component/Public/List/public/list/list.vue";
import ikzTopbg from "@/pages/Component/Public/Topbg/public/topbg/topbg.vue";
var app = getApp();
import ikz from "@/pages/Common/tools.js";
export default {
  components: {
    ikzList,
    ikzLoading,
    ikzTopbg,
  },
  data() {
    return {
      list_data: {
        list: app.globalData.agent_list,
      },
      list_css: {
        background_color: "#fff",
        border_radius: 15,
      },
      loading_css: {
        display: "flex",
      },
      service_img: app.globalData.service_img,
    };
  },
  created() {
    // var that = this;
    this.loading_css.display = "none";
  },
  methods: {
    //搜索框
    eventHandle(e) {
      console.log(e.detail.value);
      var path = "/xyb/agent/index";
      var data = {
        li_agent_area: e.detail.value,
      };
      ikz.post(path, data, (res) => {
        if (res.data.code) {
          var temp_data = res.data.data.data;
          var temp_info = [];
          for (var i = 0; i < temp_data.length; i++) {
            var temp = {
              title: temp_data[i].agent_area,
              id: temp_data[i].id,
            };
            temp_info.push(temp);
          }
          this.list_data = {
            list: temp_info,
          };
        } else {
          uni.showModal({
            title: "提示",
            content: "服务器繁忙，请稍后再试",
            showCancel: false,
            success: function (res) {},
          });
        }
      });
    },
    //点击组件返回
    returnList(e) {
      uni.showModal({
        title: "提示",
        content: "是否选择" + e.title,
        success: function (res) {
          cancel: true;
          confirm: false;
          if (res.confirm) {
            uni.setStorageSync("default_agent", e);
            uni.setStorageSync("SchoolObj", e);
            app.globalData.default_agent = e;
            uni.switchTab({
              url: "/pages/Home/index",
            });
          }
        },
        fail: function (res) {},
      });
    },
  },
};
</script>

<style>
page {
  width: 100%;
  height: 100%;
  background: #f3f3f3;
}

.ikz-school {
  width: 100%;
  height: 100%;
}

.ikz-top-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: -1;
}

.ikz-seach {
  width: 80%;
  margin: 30rpx auto;
  border-radius: 50rpx;
  background-color: #fff;
  height: 80rpx;
  display: flex;
  align-items: center;
}

.ikz-search-img {
  width: 40rpx;
  height: 40rpx;
  margin: 0 30rpx;
}
.ikz-ad {
  margin-top: 80rpx;
  margin-left: 40rpx;
  margin-right: 40rpx;
  font-size: 30rpx;
}
.ikz-ad-line2 {
  margin-top: 20rpx;
  margin-left: 40rpx;
  margin-right: 40rpx;
  font-size: 30rpx;
  white-space: pre-wrap;
}
</style>
